// pages/profile/profile.js
Page({
  data: {
    isLogin: false,
    userInfo: null,
    img1: '/styles/iconfont/wodedingdan.png',
    img2: 'https://tdesign.gtimg.com/mobile/demos/example2.png',
    img3: 'https://tdesign.gtimg.com/mobile/demos/example3.png'
  },
  onLoad(options) {},
  onShow: function () {
    let user = wx.getStorageSync('user')
    if (user) {
      this.setData({
        isLogin: true,
        userInfo: user
      })
    }
  },
  // 退出登录
  logout() {
    let that = this
    console.log("退出登录");
    wx.showModal({
      title: '提示',
      content: '您确定要退出登录吗',
      success(res) {
        if (res.confirm) {
          wx.clearStorage()
          wx.navigateTo({
            url: '/pages/login/login',
          })
        } else if (res.cancel) {}
      }
    })

  },
  scanCodeEvent: function () {
    var that = this;
    wx.scanCode({
      onlyFromCamera: true, // 只允许从相机扫码
      success(res) {
        console.log("扫码成功：" + JSON.stringify(res))

        // 扫码成功后  在此处理接下来的逻辑
        that.setData({
          scanCode: res.result
        })
      }
    })
  },
});